package ab.mes.service.impl;

import ab.mes.entity.Orders;
import ab.mes.mapper.OrdersMapper;
import ab.mes.service.OrdersService;
import ab.mes.tools.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class OrdersServiceImpl implements OrdersService {
    @Autowired
    private OrdersMapper ordersMapper;
    //获取订单信息
    public Result getOrders(){
        Result result = new Result();
        result.getMap().put("orders",ordersMapper.selectOrders1());
        return result;
    }
    //根据页数获取订单信息
    public Result getOrdersByNumber(String production_no){
        Result result = new Result();
        result.getMap().put("orders",ordersMapper.selectByNumber(production_no));
        return result;
    }
    //新增订单信息
    public Result insertOrders(Orders orders) {
        Result result = new Result();
        result.getMap().put("orders",ordersMapper.insert(orders));
        return result;
    }
    //根据id删除订单信息
    public Result deleteOrders(Integer production_no) {
        Result result = new Result();
        result.getMap().put("orders", ordersMapper.deleteByNumber(production_no));
        return result;
    }
    //修改订单信息
    public Result editOrders(Orders orders){
        Result result = new Result();
        result.getMap().put("orders",ordersMapper.updateById(orders));
        return result;
    }
}
